<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Software Engineering at Google</title>
    <link rel="icon" href="assets/images/swe_at_google.2.cover.jpg">

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="description" content="Description">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">

    <!-- gitalk   -->
    <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk/dist/gitalk.css">


</head>
<body>
<div id="app"></div>

<script>
    window.$docsify = {
        name: 'Software Engineering at Google',
        repo: 'qiangmzsx/Software-Engineering-at-Google',

        auto2top: true,


        // 侧边栏
        loadSidebar: true,
        alias: {
            '/.*/_sidebar.md': '/_sidebar.md'
        },
        subMaxLevel: 3,
        // 自动为每个页面增加标题
        // autoHeader: true,

        // 封面
        coverpage: true,

        // 搜索支持
        search: {
            maxAge: 86400000, // 过期时间，单位毫秒，默认一天
            paths: 'auto', // or 'auto'

            // 支持本地化
            placeholder: {
                '/zh-cn/': '搜索',
                '/': 'Type to search'
            },

            // 支持本地化
            noData: {
                '/zh-cn/': '找不到结果',
                '/': 'No Results'
            },

            // 避免搜索索引冲突
            // 同一域下的多个网站之间
            namespace: 'Software-Engineering-at-Google',

            // 使用不同的索引作为路径前缀（namespaces）
            // 注意：仅适用于 paths: 'auto' 模式
            //
            // 初始化索引时，我们从侧边栏查找第一个路径
            // 如果它与列表中的前缀匹配，我们将切换到相应的索引
            pathNamespaces: ['/zh-cn'],
        },
        plugins: [
            function (hook, vm) {
                hook.beforeEach(function (html) {
                    if (/githubusercontent\.com/.test(vm.route.file)) {
                        url = vm.route.file
                            .replace('raw.githubusercontent.com', 'github.com')
                            .replace(/\/master/, '/blob/master');
                    } else if (/jsdelivr\.net/.test(vm.route.file)) {
                        url = vm.route.file
                            .replace('cdn.jsdelivr.net/gh', 'github.com')
                            .replace('@master', '/blob/master');
                    } else {
                        url =
                            'https://github.com/qiangmzsx/Software-Engineering-at-Google/blob/main/' +
                            vm.route.file;
                    }
                    var editHtml = '[:memo: Edit Document](' + url + ')\n';
                    return (
                        editHtml +
                        html
                    );
                })
            },
            function (i) {
                // 加载 Gitalk 元素
                var e = Docsify.dom;
                i.mounted(function (i) {
                    var n = e.create("div");
                    n.id = "gitalk-container";
                    var t = e.getNode("#main");
                    n.style = "width: " + t.clientWidth + "px; margin: 0 auto 20px;", e.appendTo(e.find(".content"), n)
                }), i.doneEach(function (i) {
                    for (var n = document.getElementById("gitalk-container"); n.hasChildNodes();) n.removeChild(n.firstChild);
                })
            },
            function (hook, vm) {
                hook.doneEach(function () {
                    // remove gitalk-container
                    document.getElementById('gitalk-container').innerHTML = "";
                    // 渲染
                    NewGitalk().render('gitalk-container');
                })
            }
        ],
    }
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//cdn.jsdelivr.net/npm/docsify@4/lib/plugins/search.min.js"></script>

<!-- Pagination -->
<script src="//cdn.jsdelivr.net/npm/docsify-pagination/dist/docsify-pagination.min.js"></script>

<!-- gitalk -->
<script src="//cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.js"></script>

<!-- Medium's 风格的图片缩放插件 -->
<script src="//cdn.jsdelivr.net/npm/docsify/lib/plugins/zoom-image.min.js"></script>

<script src="//cdn.jsdelivr.net/npm/crypto-js@4.1.1/crypto-js.js"></script>

<script>

    function NewGitalk() {
        // 除去param
        const hashPath = location.hash.indexOf("?id=") === -1 ? location.hash : location.hash.substring(0, location.hash.indexOf("?id="));
        const hrefPath = location.hash.indexOf("?id=") === -1 ? location.href : location.href.substring(0, location.href.indexOf("?id="));
        // id 50字符限制
        const md5Id = CryptoJS.MD5(hashPath).toString();

        return new Gitalk({
            clientID: '92436d65d807aaf80fcd',
            clientSecret: '8df80f61b0d3e4389747e74616c3fd7ad7d359d5',
            repo: 'SwEAtGoogleTalk',
            owner: 'suixinio',
            admin: ['suixinio'],
            id: md5Id,
            body: hrefPath,
            distractionFreeMode: false
        });
    }
</script>

</body>
</html>
